const mysql = require('mysql');

const connection = mysql.createConnection({
    host: "localhost",
    user: 'root',
    password: "root",
    port: 3306,
    database: "mydb"
})
//启用
connection.connect();
// 查询语句
const sql = `select * from blogs`;
// 返回值
connection.query(sql, (err, result) => {
    if (err) {
        console.error("error", err)
        return
    }
    console.log('result', result);
})
//结束
connection.end()